﻿using RewriteWeatherApp.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// 公众号主题
/// </summary>
namespace RewriteWeatherApp
{
    public class OfficialAccounts : IMyAccountsSubject
    {
        string username;
        DateTime updatetime;
        private event Action<string, DateTime> observers;
        public void NotifyObserver()
        {
            observers?.Invoke(username,updatetime);

        }

        public void RegisterObserver(IMyAccountsObserver observer)
        {
            observers += observer.Update;
        }

        public void RemoveObserver(IMyAccountsObserver observer)
        {
            observers -= observer.Update;
        }
        public void MeasurementsChanged()
        {
            NotifyObserver();
        }

        public void SetMeasurements(string username,DateTime updatetime)
        {
            //设置数值 发生变化 通知所有观察者
            this.username = username;
            this.updatetime = updatetime;         
            MeasurementsChanged();
        }
    }
}
